home *** CD-ROM | disk | FTP | other *** search
/ Freelog 22 / freelog 22.iso / Prog / Djgpp / GPC2952B.ZIP / info / gpc.i4 < prev    next >
Encoding:
GNU Info File  |  2001-02-09  |  49.3 KB  |  1,436 lines

  1. This is gpc.info, produced by makeinfo version 4.0 from gpc.texi.
  2.  
  3. INFO-DIR-SECTION GNU programming tools
  4. START-INFO-DIR-ENTRY
  5. * GPC: (gpc).                   The GNU Pascal Compiler.
  6. END-INFO-DIR-ENTRY
  7. INFO-DIR-SECTION Individual utilities
  8. START-INFO-DIR-ENTRY
  9. * GPC: (gpc)Invoking GPC.       The GNU Pascal Compiler.
  10. END-INFO-DIR-ENTRY
  11.  
  12.    This file documents the GNU Pascal Compiler.
  13.  
  14.    Copyright (C) 1988, 1996-2001 Free Software Foundation, Inc.
  15.  
  16.    Permission is granted to make and distribute verbatim copies of this
  17. manual provided the copyright notice and this permission notice are
  18. preserved on all copies.
  19.  
  20.    Permission is granted to copy and distribute modified versions of
  21. this manual under the conditions for verbatim copying, provided also
  22. that the sections entitled "GNU General Public License", "The GNU
  23. Project", "The GNU Manifesto" and "Funding for Free Software" are
  24. included exactly as in the original, and provided that the entire
  25. resulting derived work is distributed under the terms of a permission
  26. notice identical to this one.
  27.  
  28.    Permission is granted to copy and distribute translations of this
  29. manual into another language, under the above conditions for modified
  30. versions, except that the sections entitled "GNU General Public
  31. License", "The GNU Project", "The GNU Manifesto" and "Funding for Free
  32. Software" and this permission notice, may be included in translations
  33. approved by the Free Software Foundation instead of in the original
  34. English.
  35.  
  36. 
  37. File: gpc.info,  Node: Files,  Next: Built-in Constants,  Prev: BP Procedural Types,  Up: Borland Pascal
  38.  
  39. Files
  40. =====
  41.  
  42.    * GPC supports files like in Borland Pascal, including untyped files,
  43.      `BlockRead', `BlockWrite' and `Assign'. Instead of `Assign', you
  44.      can also use the `Bind' mechanism of Extended Pascal.
  45.  
  46.      Besides the routines supproted by BP, there are many more routines
  47.      available that deal with files, file names and similar things in a
  48.      portable way. In contrast to Borland Pascal, you don't have to use
  49.      any platform-specific units to do these kinds of things, though
  50.      portable emulations of those units (e.g., of the `Dos' and
  51.      `WinDos' units) are also available for compatibility.
  52.  
  53.  
  54. 
  55. File: gpc.info,  Node: Built-in Constants,  Next: Built-in Operators in BP and GPC,  Prev: Files,  Up: Borland Pascal
  56.  
  57. Built-in Constants
  58. ==================
  59.  
  60.    * The `MaxInt', `MaxLongInt', `Pi' constants are supported like in
  61.      BP.
  62.  
  63.    * Other built-in constants: GNU Pascal has `MaxChar', `MaxReal',
  64.      `MinReal', `EpsReal' and a number of other useful constants.
  65.  
  66. 
  67. File: gpc.info,  Node: Built-in Operators in BP and GPC,  Next: Built-in Procedures and Functions,  Prev: Built-in Constants,  Up: Borland Pascal
  68.  
  69. Built-in Operators in BP and GPC
  70. ================================
  71.  
  72.    Besides the operators found in Borland Pascal, GNU Pascal supports
  73. the following operators:
  74.  
  75.    * Exponentiation: According to Extended Pascal, GNU Pascal supports
  76.      the exponentiation operators `pow' and `**' which do not exist in
  77.      Borland Pascal. You can use `x pow y' for integer and `x ** y' for
  78.      real or complex exponents. The basis may be integer, real or
  79.      complex in both cases.
  80.  
  81.    * Address operator: GNU Pascal accepts Borland's `@', but also `&'
  82.      as an address operator.
  83.  
  84.    * GNU Pascal has a symmetric set difference operator `set1 >< set2'.
  85.      For more about this, see *Note Set Operations::.
  86.  
  87. 
  88. File: gpc.info,  Node: Built-in Procedures and Functions,  Next: Special Parameters,  Prev: Built-in Operators in BP and GPC,  Up: Borland Pascal
  89.  
  90. Built-in Procedures and Functions
  91. =================================
  92.  
  93.    * `GetMem' and `FreeMem' are supported like in BP.  `GetMem' can
  94.      also act as a function in GNU Pascal:
  95.  
  96.           program GetMemFunctionDemo;
  97.           var p : Pointer;
  98.           begin
  99.             p := GetMem (1024)
  100.           end.
  101.  
  102.      The second parameter to `FreeMem' is ignored by GNU Pascal and may
  103.      be omitted. Memory blocks are always freed with the same size they
  104.      were allocated with.
  105.  
  106.      Remark: Extended Pascal Schema types provide a cleaner approach to
  107.      most of the applications of `GetMem' and `FreeMem'.
  108.  
  109.    * `Min' and `Max': GNU Pascal has built-in `Min' and `Max' functions
  110.      (two arguments) which work for all ordinal types (`Integer',
  111.      `Char', ...) plus `Real'.
  112.  
  113.    * `UpCase', `High', `Low' and similar functions are built-in. In
  114.      contrast to Borland Pascal, GNU Pascal's `UpCase' function is
  115.      aware of non-ASCII characters of certain languages (e.g., accented
  116.      letters and "umlauts"), but for compatibility this feature is
  117.      disables in `--borland-pascal' mode. There is also a `LoCase'
  118.      function.
  119.  
  120.    * `Lo', `Hi', `Swap' functions: not built-in, but available in the
  121.      `System' unit.
  122.  
  123. 
  124. File: gpc.info,  Node: Special Parameters,  Next: Miscellaneous,  Prev: Built-in Procedures and Functions,  Up: Borland Pascal
  125.  
  126. Special Parameters
  127. ==================
  128.  
  129.    * Untyped reference parameters can be denoted by
  130.  
  131.           procedure Foo (var x);
  132.  
  133.      like in Borland Pascal. In GNU Pascal, you can also use
  134.  
  135.           procedure Foo (var x : Void);
  136.  
  137.    * GNU Pascal defines "ellipsis" parameters for variable argument
  138.      lists:
  139.  
  140.           procedure Foo (a : Integer; ...);
  141.  
  142.      However, GPC does not (yet) provide a portable mechanism to access
  143.      the additional arguments.
  144.  
  145.    * Structured function return values: According to Extended Pascal,
  146.      GNU Pascal allows functions to return records and arrays.
  147.  
  148.    * BP style "open array parameters"
  149.           procedure Foo (a : array of Integer);
  150.      are implemented. However, Standard Pascal `conformant array
  151.      parameters' are usually a cleaner mechanism to pass arrays of
  152.      variable size.
  153.  
  154.    * Besides BP compatible procedural types and procedure pointers
  155.      (*note BP Procedural Types::), GNU Pascal supports Standard
  156.      Pascal's procedural parameters:
  157.  
  158.           procedure DrawGraph (function f (x : Real) : Real);
  159.  
  160. 
  161. File: gpc.info,  Node: Miscellaneous,  Next: BP and Extended Pascal,  Prev: Special Parameters,  Up: Borland Pascal
  162.  
  163. Miscellaneous
  164. =============
  165.  
  166.    * Headlines: According to Extended Pascal, a program headline must
  167.      contain the program's parameters:
  168.  
  169.           program Foo (Input, Output);
  170.           begin
  171.           end.
  172.  
  173.      In GNU Pascal, headline parameters are optional. If the headline is
  174.      omitted entirely, a warning is given unless you have specified
  175.      `--borland-pascal' in the command line.
  176.  
  177.    * `case' statements: In a `case' statement, GNU Pascal allows
  178.      `otherwise' (according to Extended Pascal) as an alternative to
  179.      `else':
  180.  
  181.           program CaseOtherwiseDemo;
  182.           var x : Integer;
  183.           begin
  184.             ReadLn (x);
  185.             case x of
  186.               1 : WriteLn ('one');
  187.               2 : WriteLn ('two');
  188.               otherwise
  189.                 WriteLn ('many')
  190.             end
  191.           end.
  192.  
  193.      Note: In the absence of a `case' or `otherwise' branch, missing
  194.      cases labels cause an error in Extended Pascal (which goes
  195.      unnoticed in Borland Pascal). GPC does not give this error, but a
  196.      warning if the `-Wswitch' option is given, however only for
  197.      enumeration types.
  198.  
  199.    * Character constants: BP compatible character constants like `^M'
  200.      as well as `#13' are implemented into GNU Pascal.
  201.  
  202.    * Sets: GNU Pascal has a `Card' function for sets which counts their
  203.      elements. Unlike Borland Pascal, GNU Pascal does not limit sets to
  204.      the range 0 .. 255.
  205.  
  206.    * Inline: GNU Pascal allows "inline" Pascal procedures and
  207.      functions, while Borland Pascal only allows machine code to be
  208.      inlined:
  209.  
  210.      Borland Pascal:
  211.  
  212.           function Max (x, y : Integer) : Integer;
  213.             inline ($58 / $59 / $3b / $c1 / $7f / $01 / $91);
  214.  
  215.      GNU Pascal:
  216.  
  217.           program InlineDemo;
  218.           
  219.           inline function Max (x, y : Integer) : Integer;
  220.           begin
  221.             if x > y then
  222.               Max := x
  223.             else
  224.               Max := y
  225.           end;
  226.           
  227.           begin
  228.             WriteLn (Max (42, 17), ' ', Max (-4, -2))
  229.           end.
  230.  
  231.      (Actually, a more general `Max' function is already built-in.)
  232.  
  233.      This feature is not so important as it might seem because in
  234.      optimization level 3 or higher (*note GPC Options::), GNU Pascal
  235.      automatically inlines short procedures and functions.
  236.  
  237. 
  238. File: gpc.info,  Node: BP and Extended Pascal,  Next: Portability hints,  Prev: Miscellaneous,  Up: Borland Pascal
  239.  
  240. BP and Extended Pascal
  241. ======================
  242.  
  243.    Pascal is a well-known programming language and hardly needs to be
  244. described here. Note, however, that there is a large difference between
  245. the language used by the BP compiler and the Pascal Standards.
  246.  
  247.    Extended Pascal is a standardized language based on the original
  248. Standard Pascal, but with significant extensions. Unfortunately,
  249. Borland Pascal does not conform to any of the Pascal standards.
  250. Writing a program that both complies to Extended Pascal (or even
  251. Standard Pascal) and compiles with BP is almost impossible for any
  252. non-trivial task.
  253.  
  254.    On the other hand, BP has some nice features that make it very
  255. powerful in the environments in which it runs. However, some of those
  256. features are of little use on non-Dos systems and would not be good
  257. candidates for standardization.
  258.  
  259.    There are also several BP features which are semantically similar to
  260. features in Standard Pascal or Extended Pascal, but syntactically
  261. different.
  262.  
  263.    Therefore, in order to be useful to users coming from either side,
  264. GPC supports both the standards and the BP dialect as good as possible.
  265. By default, GPC allows features from any dialect it knows.  By giving a
  266. dialect option such as `--borland-pascal' or `--extended-pascal', you
  267. can tell GPC to disable the features not found in that dialect, and to
  268. adjust its warning behaviour to the dialect.
  269.  
  270.    The different sets of reserved words are a little problem, but GPC
  271. solves it by making the words in question only "conditionally reserved"
  272. which works transparently without problems in most cases. Still, giving
  273. a dialect option will disable all keywords not part of this dialect.
  274.  
  275.    Apart from this, there are surprisingly few real conflicts between
  276. the dialects. Therefore, you can usually compile your BP code without
  277. the `--borland-pascal' option and make use of all of GPC's features.
  278. You might be surprised, though, when GPC accepts things you didn't know
  279. were allowed. :-)
  280.  
  281.    Finally, if you want to make use of some of GPC's extensions
  282. (compared to BP) and still keep the code compileable with BP without
  283. using `ifdef's all over the place, we suggest you look at the unit
  284. `gpc-bp.pas', shipped with GPC, which contains BP versions of some of
  285. GPC's features. Please read the comments at the beginning of the unit
  286. to find out more about it.
  287.  
  288. 
  289. File: gpc.info,  Node: Portability hints,  Prev: BP and Extended Pascal,  Up: Borland Pascal
  290.  
  291. Portability hints
  292. =================
  293.  
  294.    GPC offers you the possibility to make your code fully portable to
  295. each of the many platforms supported by GPC. It would be a pity not to
  296. make use of this.
  297.  
  298.    This section lists some known pitfalls that often hinder otherwise
  299. well-written programs to take full advantage of GPC. If you have never
  300. used any compiler but Borland Pascal and similar compilers, some of the
  301. advices might look strange to you. But this is just the same level of
  302. strangeness that your old programs will have for you once you have
  303. understood the principles of cross-platform portability. Remember that
  304. many tricks you have always been applying almost automatically in
  305. Borland Pascal were necessary to overcome certain limitations of the
  306. Dos platform and to compensate for the compiler's missing optimization.
  307. Programming with an optimizing compiler like GPC for platforms without
  308. a 64 kB limit is a completely new experience - and perhaps it is among
  309. the reasons why you are now working with GPC in the first place?
  310.  
  311. Portability - why?
  312. ------------------
  313.  
  314.    _Okay - but why should I bother and make my program portable?  I
  315. know that all who want to use my program are running WXYZ-OS anyway._
  316.  
  317.    Yes, but that's the result of a self-fulfilling prophecy. It depends
  318. on *you* whether it will always remain like this or not.  Consider a
  319. program ABC written for a single platform, WXYZ-OS.  Naturally, only
  320. WXYZ-OS-users get interested in ABC. The author gets feedback only from
  321. WXYZ-OS users and does not see any reason to make the program
  322. cross-platform. Then people realize that if they want to run ABC they
  323. must move to WXYZ-OS. The author concludes that people only want
  324. WXYZ-OS programs, and so on.
  325.  
  326.    To break out, just create a portable version of your program *now*.
  327. Then all OSes have equal chances to show their abilities when running
  328. your program, and your customers can choose their OS. Then, maybe, they
  329. decide to use your program just for the reason that they can be sure
  330. that it will run on all present and future platforms and not only on a
  331. specific one - who knows?
  332.  
  333.    _My program is a tool specifically designed to make the best of the
  334. STUV feature of WXYZ-OS. There is no point in making it portable._
  335.  
  336.    How much do you know about non-WXYZ-OSes? Just ask an expert how the
  337. STUV feature is named elsewhere. Be sure, if it is of value, it exists
  338. almost everywhere.
  339.  
  340. Low-level features
  341. ==================
  342.  
  343.    _I am using a lot of low-level stuff in my programs, so they cannot
  344. be portable._
  345.  
  346.    You do not use those low-level routines directly in your high-level
  347. routines, do you? There should always be a layer "in-between" that
  348. encapsulates the low-level routines and present an API to your program
  349. that exactly reflects the needs of your application.  This "API in
  350. between" is the point where you can exchange the low-level routines by
  351. portable calls to GPC's Run Time System.
  352.  
  353.    If you do not have such a layer in-between, then the API of the
  354. low-level routines you call are your first approximation for such a
  355. layer.  If you have ever thought "it would be great if that API
  356. function had that additional parameter", then your own extended version
  357. of that API function that *has* that parameter can become part of your
  358. "API in between".  But then don't stop here: Certainly the API of the
  359. OS is *not* ideal for your program's needs. Just create more routines
  360. that encapsulate all OS-specific stuff ...
  361.  
  362.    When the low-level stuff in question consists of interrupts,
  363. assembler and similar things, then the first thing you need is a
  364. portable replacement of the functionality. Fortunately, GPC covers many
  365. things already in Pascal that require assembler in Borland Pascal:
  366.  
  367.    * GPC's libraries come with source. You do not need to learn
  368.      assembler and to write a complete replacement for the CRT unit if
  369.      you only want to adapt some tiny detail in the behavior of CRT to
  370.      your personal needs.
  371.  
  372.    * GPC's Run Time System is fairly complete. For example, to extract
  373.      the assigned name of a `File' variable, you do not need to mess
  374.      around with the internal representation of those variables, but you
  375.      can type `uses GPC' and then use the `FileName' function.  In the
  376.      same unit, you will find a `FileExists' function and much more.
  377.  
  378.    * Manually "constructing" an object is covered by the `SetType'
  379.      procedure in GPC. This is where Turbo Vision uses assembler to load
  380.      an object from a stream.
  381.  
  382.    * Calling local procedures and functions via pointers simply works in
  383.      GPC. This is another place where, for instance, Turbo Vision's
  384.      `ForEach' method uses assembler, while GPC lets you do the same
  385.      thing in Pascal.
  386.  
  387.    * Interfacing with the OS can be done through library calls. GPC's
  388.      built-in functions and the GPC unit offer a rather complete set of
  389.      routines. And again: You have the source of all this.
  390.  
  391.    * Using `FillChar' and `Move' does not necessarily speed up your
  392.      programs. Using them to circumvent restrictions of the language
  393.      (e.g. for direct assignments between variables of object or file
  394.      type) is asking for trouble. `FillChar' was created in UCSD Pascal
  395.      to set consecutive chars in a string to the same value, and `Move'
  396.      was created to move the chars within the same string.  Better do
  397.      not use them for other purposes.
  398.  
  399.  
  400. 
  401. File: gpc.info,  Node: Invoking GPC,  Next: Programming,  Prev: Borland Pascal,  Up: Top
  402.  
  403. Command Line Options supported by GNU Pascal.
  404. *********************************************
  405.  
  406.    GPC is a command-line compiler, i.e., to compile a program you have
  407. to invoke `gpc' passing it the name of the file you want to compile,
  408. plus options.
  409.  
  410.    GPC supports all command-line options that GCC knows. For a complete
  411. reference and descriptions of all options, see *Note GCC Command
  412. Options: (gcc)Invoking GCC.  Below, you will find a list of the
  413. additional options that GPC supports, and a list of GPC's most
  414. important options (including some of those supported by GCC as well).
  415.  
  416.    You can mix options and file names on the command line. For the most
  417. part, the order doesn't matter. Order does matter, e.g., when you use
  418. several options of the same kind; for example, if you specify `-L' more
  419. than once, the directories are searched in the order specified. _Note:_
  420. Since many options have multiletter names; multiple single-letter
  421. options may _not_ be grouped as is possible with many other programs:
  422. `-dr' is very different from `-d -r'.
  423.  
  424.    Many options have long names starting with `--' or, completely
  425. equivalent `-f'. E.g., `--mixed-comments' is the same as
  426. `-fmixed-comments'. Some options tell GPC when to give warnings, i.e.
  427. diagnostic messages that report constructs which are not inherently
  428. erroneous but which are risky or suggest there may have been an error.
  429. Those options start with `-W'.
  430.  
  431.    Most GPC specific options can also be changed during one compilation
  432. by using compiler directives in the source, e.g. `{$X+}' or
  433. `{$extended-syntax}' for `--extended-syntax' (*note Compiler
  434. Directives::).
  435.  
  436.    GPC understands the same environment variables GCC does (*note
  437. Environment Variables Affecting GCC: (gcc)Environment Variables.).  In
  438. addition, GPC recognizes `GPC_EXEC_PREFIX' with the same meaning that
  439. `GCC_EXEC_PREFIX' has to GCC. GPC also recognizes `GCC_EXEC_PREFIX',
  440. but `GPC_EXEC_PREFIX' takes precedence.
  441.  
  442. * Menu:
  443.  
  444. * GPC Command Line Options::  GPC options besides those of GCC.
  445. * GPC Options::               The most commonly used options to GPC.
  446.  
  447. 
  448. File: gpc.info,  Node: GPC Command Line Options,  Next: GPC Options,  Up: Invoking GPC
  449.  
  450. GPC options besides those of GCC.
  451. =================================
  452.  
  453.    The following table lists the command line options GPC understands
  454. in addition to those understood by GCC.
  455.  
  456. `--standard-pascal-level-0'
  457.      Reject conformant arrays and anything besides ISO-7185 Standard
  458.      Pascal.
  459.  
  460. `--standard-pascal'
  461.      Reject anything besides ISO-7185 Standard Pascal.
  462.  
  463. `--extended-pascal'
  464.      Reject anything besides ISO-10206 Extended Pascal.
  465.  
  466. `--object-pascal'
  467.      Reject anything besides (the implemented parts of) ANSI draft
  468.      Object Pascal.
  469.  
  470. `--borland-pascal'
  471.      Try to emulate Borland Pascal, version 7.0.
  472.  
  473. `--delphi'
  474.      Try to emulate Borland Pascal, version 7.0, with some Delphi
  475.      extensions.
  476.  
  477. `--pascal-sc'
  478.      Be strict about the implemented Pascal-SC extensions.
  479.  
  480. `--gnu-pascal'
  481.      Undo the effect of a previous `--foo-pascal', `--delphi' or
  482.      `--pascal-sc' switch.
  483.  
  484. `--lines'
  485.      (Unimplemented switch for debugging).
  486.  
  487. `--debug-tree'
  488.      (Internal directive for debugging the compiler).
  489.  
  490. `--debug-gpi'
  491.      (Internal directive for debugging the compiler).
  492.  
  493. `--debug-source'
  494.      (Internal directive for debugging the compiler).
  495.  
  496. `--progress-messages'
  497.      Output source file names and line numbers while compiling.
  498.  
  499. `--progress-bar'
  500.      Output number of processed lines while compiling.
  501.  
  502. `--autolink'
  503.      Automatically link object files provided by units/modules or `{$L
  504.      ...}' (default).
  505.  
  506. `--no-autolink'
  507.      Do not automatically link object files provided by
  508.      units/modules/`{$L ...}'.
  509.  
  510. `--automake'
  511.      Automatically compile changed units/modules/`{$L ...}' files and
  512.      link the object files provided.
  513.  
  514. `--no-automake'
  515.      Same as `--no-autolink'.
  516.  
  517. `--autobuild'
  518.      Automatically compile all units/modules/`{$L ...}' files and link
  519.      the object files provided.
  520.  
  521. `--no-autobuild'
  522.      Same as `--no-autolink'.
  523.  
  524. `--amtmpfile'
  525.      (Internal switch used for AutoMake).
  526.  
  527. `--extended-syntax'
  528.      Enable certain `dangerous' features such as ignoring function
  529.      results, pointer arithmetic or using `CString's as strings (same
  530.      as `{$X+}').
  531.  
  532. `--no-extended-syntax'
  533.      Disable the dangerous features enabled by `--extended-syntax'
  534.      (default; same as `{$X-}').
  535.  
  536. `--signed-char'
  537.      Let `Char' be a signed type.
  538.  
  539. `--no-signed-char'
  540.      Let `Char' be an unsigned type.
  541.  
  542. `--unsigned-char'
  543.      Let `Char' be an unsigned type.
  544.  
  545. `--no-unsigned-char'
  546.      Let `Char' be a signed type.
  547.  
  548. `--short-circuit'
  549.      Guarantee short-circuit Boolean evaluation (default; same as
  550.      `{$B-}').
  551.  
  552. `--no-short-circuit'
  553.      Do not guarantee short-circuit Boolean evaluation (same as
  554.      `{$B+}').
  555.  
  556. `--mixed-comments'
  557.      Allow comments like `{ ... *)' as required in ISO Pascal (default
  558.      in Standard Pascal mode).
  559.  
  560. `--no-mixed-comments'
  561.      Ignore `{' and `}' within `(* ... *)' comments and vice versa
  562.      (default).
  563.  
  564. `--nested-comments'
  565.      Allow nested comments like `{ { } }' and `(* (* *) *)'.
  566.  
  567. `--no-nested-comments'
  568.      Do not allow nested comments (default).
  569.  
  570. `--delphi-comments'
  571.      Allow Delphi style `//' comments (default).
  572.  
  573. `--no-delphi-comments'
  574.      Do not allow Delphi style `//' comments.
  575.  
  576. `--macros'
  577.      Expand macros (default).
  578.  
  579. `--no-macros'
  580.      Do not expand macros (default with `--borland-pascal' or
  581.      `--delphi').
  582.  
  583. `--ignore-function-results'
  584.      Do not complain when a function is called like a procedure.
  585.  
  586. `--no-ignore-function-results'
  587.      Complain when a function is called like a procedure (default).
  588.  
  589. `--borland-char-constants'
  590.      Allow for Borland-style character constants like `#27' or `^L'
  591.      (default).
  592.  
  593. `--no-borland-char-constants'
  594.      Reject Borland-style character constants like `#27' or `^L'
  595.      (default in Standard Pascal mode).
  596.  
  597. `--truncate-strings'
  598.      Truncate strings being assigned to other strings of too short
  599.      capacity..
  600.  
  601. `--no-truncate-strings'
  602.      Treat string assignments to other strings of too short capacity as
  603.      errors..
  604.  
  605. `--exact-compare-strings'
  606.      Do not blank-pad strings for comparisons.
  607.  
  608. `--no-exact-compare-strings'
  609.      Blank-pad strings for comparisons.
  610.  
  611. `--io-checking'
  612.      Do automatic run-time checks after I/O operations (same as
  613.      `{$I+}').
  614.  
  615. `--no-io-checking'
  616.      Do not check I/O operations automatically (same as `{$I-}').
  617.  
  618. `--write-clip-strings'
  619.      In write statements, truncate strings exceeding their field width
  620.      (`Write (SomeLongString : 3)').
  621.  
  622. `--no-write-clip-strings'
  623.      Do not truncate strings exceeding their field width.
  624.  
  625. `--write-real-blank'
  626.      Output a blank in front of positive reals in exponential form
  627.      (default).
  628.  
  629. `--no-write-real-blank'
  630.      Do not output a blank in front of positive reals in exponential
  631.      form.
  632.  
  633. `--write-capital-exponent'
  634.      Write real exponents with a capital `E'.
  635.  
  636. `--no-write-capital-exponent'
  637.      Write real exponents with a lowercase `e'.
  638.  
  639. `--transparent-file-names'
  640.      Derive external file names from variable names.
  641.  
  642. `--no-transparent-file-names'
  643.      Do not derive external file names from variable names (default).
  644.  
  645. `--field-widths'
  646.      Comma-separated list of default field widths for Integer, Real,
  647.      Boolean, LongInt, LongReal.
  648.  
  649. `--no-field-widths'
  650.      Reset the default field widths.
  651.  
  652. `--pedantic'
  653.      Warn about everything rejected in some dialect, e.g. redefinition
  654.      of its keywords.
  655.  
  656. `--no-pedantic'
  657.      Don't give pedantic warnings.
  658.  
  659. `--stack-checking'
  660.      Enable stack checking (same as `{$S+}').
  661.  
  662. `--no-stack-checking'
  663.      Disable stack checking (same as `{$S-}').
  664.  
  665. `--typed-address'
  666.      Make the result of the address operator typed (same as `{$T+}',
  667.      default).
  668.  
  669. `--no-typed-address'
  670.      Make the result of the address operator an untyped pointer (same
  671.      as `{$T-}').
  672.  
  673. `--setlimit'
  674.      Define the range for `set of Integer' etc..
  675.  
  676. `--gpc-main'
  677.      External name for the program's entry point (default: `main').
  678.  
  679. `--interface-only'
  680.      Compile only the interface part of a unit/module and exit.
  681.  
  682. `--implementation-only'
  683.      Do not produce a GPI file; only compile the implementation part.
  684.  
  685. `--executable-file-name'
  686.      Name for the output file, if specified; otherwise derive from main
  687.      source file name.
  688.  
  689. `--unit-path'
  690.      Directories where to look for unit/module sources.
  691.  
  692. `--no-unit-path'
  693.      Forget about directories where to look for unit/module sources.
  694.  
  695. `--object-path'
  696.      Directories where to look for additional object (and source) files.
  697.  
  698. `--no-object-path'
  699.      Forget about directories where to look for additional object (and
  700.      source) files.
  701.  
  702. `--executable-path'
  703.      Path where to create the executable file.
  704.  
  705. `--no-executable-path'
  706.      Create the executable file in the directory where the main source
  707.      is (default).
  708.  
  709. `--unit-destination-path'
  710.      Path where to create object and GPI files.
  711.  
  712. `--no-unit-destination-path'
  713.      Create object and GPI files in the current directory (default).
  714.  
  715. `--object-destination-path'
  716.      Path where to create additional object files.
  717.  
  718. `--no-object-destination-path'
  719.      Create additional object files in the current directory (default).
  720.  
  721. `--no-default-paths'
  722.      Do not add a default path to the unit and object path.
  723.  
  724. `--gpi-destination-path'
  725.      (Internal switch used for AutoMake).
  726.  
  727. `--uses'
  728.      Add an implicit `uses' clause.
  729.  
  730. `--cidefine'
  731.      Define a case-insensitive macro.
  732.  
  733. `--csdefine'
  734.      Define a case-sensitive macro.
  735.  
  736. `-Wwarnings'
  737.      Enable warnings (same as `{$W+}').
  738.  
  739. `-Wno-warnings'
  740.      Disable warnings (same as `{$W-}').
  741.  
  742. `-Wfield-name-problem'
  743.      Warn about ignored field names in initializers (default).
  744.  
  745. `-Wno-field-name-problem'
  746.      Do not warn about ignored field names in initializers.
  747.  
  748. `-Wobject-directives'
  749.      Warn about unimplemented `private', `protected' and `public'
  750.      directives (default).
  751.  
  752. `-Wno-object-directives'
  753.      Do not warn about unimplemented `private', `protected' and
  754.      `public' directives.
  755.  
  756. `-Wtyped-const'
  757.      Warn about misuse of typed constants as initialized variables
  758.      (default).
  759.  
  760. `-Wno-typed-const'
  761.      Do not warn about misuse of typed constants as initialized
  762.      variables.
  763.  
  764. `-Wnear-far'
  765.      Warn about use of useless `near' or `far' directives (default).
  766.  
  767. `-Wno-near-far'
  768.      Do not warn about use of useless `near' or `far' directives.
  769.  
  770. `-Wunderscore'
  771.      Warn about double/leading/trailing underscores in identifiers.
  772.  
  773. `-Wno-underscore'
  774.      Do not warn about double/leading/trailing underscores in
  775.      identifiers.
  776.  
  777. `-Wmixed-comments'
  778.      Warn about mixed comments like `{ ... *)'.
  779.  
  780. `-Wno-mixed-comments'
  781.      Do not warn about mixed comments.
  782.  
  783. `-Wnested-comments'
  784.      Warn about nested comments like `{ { } }'.
  785.  
  786. `-Wno-nested-comments'
  787.      Do not warn about nested comments.
  788.  
  789. 
  790. File: gpc.info,  Node: GPC Options,  Prev: GPC Command Line Options,  Up: Invoking GPC
  791.  
  792. The most commonly used options to GPC
  793. =====================================
  794.  
  795.    As the most simple example, calling
  796.  
  797.      gpc foo.pas
  798.  
  799.    tells GPC to compile the source file `foo.pas' and to produce an
  800. executable of the default name which is `foo.exe' on EMX, `a.exe' on
  801. DJGPP, and `a.out' on most other platforms.
  802.  
  803.    Users familiar with BP, please note that you have to give the file
  804. name extension `.pas': GPC is a common interface for a Pascal compiler,
  805. a C, ObjC and C++ compiler, an assembler, a linker, and perhaps an Ada
  806. and a FORTRAN compiler. From the extension of your source file GPC
  807. figures out which compiler to run. GPC recognizes Pascal sources by the
  808. extension `.pas', `.p', `.pp' or `.dpr'. GPC also accepts source files
  809. in other languages (e.g., `.c' for C) and calls the appropriate
  810. compilers for them. Files with the extension `.o' or without any special
  811. recognized extension are considered to be object files or libraries to
  812. be linked.
  813.  
  814.    Another example:
  815.  
  816.      gpc -O2 -Wall --executable-file-name --automake --unit-path=units foo.pas
  817.  
  818.    This will compile the source file `foo.pas' to an executable named
  819. `foo' (`--executable-file-name') with fairly good optimization (`-O2'),
  820. warning about possible problems (`-Wall'). If the program uses units or
  821. imports modules, they will be searched for in a directory called `units'
  822. (`--unit-path') and automatically compiled and linked (`--automake').
  823.  
  824.    The following table lists the most commonly used options to GPC.
  825.  
  826. `--automake'
  827.      Check whether modules/units used must be recompiled and do the
  828.      recompilation when necessary.
  829.  
  830. `--unit-path=DIR[:DIR...]'
  831.      Search the given directories for units and object files.
  832.  
  833. `--object-path=DIR[:DIR...]'
  834.      Search the given directories for object files.
  835.  
  836. `--unit-destination-path=DIR'
  837.      Place units compiled into the directory DIR. The default is the
  838.      current directory.
  839.  
  840. `--object-destination-path=DIR'
  841.      Place object files compiled into the directory DIR. The default is
  842.      the directory given with `--unit-destination-path'.
  843.  
  844. `--executable-path=DIR'
  845.      Place the executable compiled into the directory DIR. The default
  846.      is the main source file's directory.
  847.  
  848. `-o FILE'
  849.      Place output in file FILE. This applies regardless to whatever
  850.      sort of output is being produced, whether it be an executable file,
  851.      an object file, an assembler file, etc.
  852.  
  853.      Since only one output file can be specified, it does not make sense
  854.      to use `-o' when compiling more than one input file, unless you
  855.      are producing an executable file as output.
  856.  
  857. `--executable-file-name[=NAME]'
  858.      Derive the executable file name from the source file name, or use
  859.      NAME as the executable file name. The difference to the `-o'
  860.      option is that `--executable-file-name' considers the
  861.      `--executable-path', while `-o' does not and accepts a file name
  862.      with directory. Furthermore, `--executable-file-name' only applies
  863.      to executables, not to other output formats selected.
  864.  
  865. `-LDIR'
  866.      Search the directory DIR for libraries. Can be given multiple
  867.      times.
  868.  
  869. `-IDIR'
  870.      Search the directory DIR for include files. Can be given multiple
  871.      times.
  872.  
  873. `-lLIBRARY'
  874.      Search the library named LIBRARY when linking. This option must be
  875.      placed on the command line _after_ all source or object files or
  876.      other libraries that reference the library.
  877.  
  878. `-O[N]'
  879.      Select the optimization level. Without optimization (or `-O0'
  880.      which is the default), the compiler's goal is to reduce the
  881.      compilation time and to make debugging produce the expected
  882.      results.  Statements are independent: if you stop the program with
  883.      a breakpoint between statements, you can then assign a new value to
  884.      any variable or change the program counter to any other statement
  885.      in the same routine and get exactly the results you would expect
  886.      from the source code.
  887.  
  888.      With optimization, the compiler tries to reduce code size and
  889.      execution time. The higher the value of N, the more optimizations
  890.      will be done, but the longer the compilation will take.
  891.  
  892.      If you use multiple `-O' options, with or without N, the last such
  893.      option is the one that is effective.
  894.  
  895. `-g'
  896.      Produce debugging information suitable for `gdb'. Unlike some
  897.      other compilers, GNU Pascal allows you to use `-g' with `-O'. The
  898.      shortcuts taken by optimized code may occasionally produce
  899.      surprising results: some variables you declared may not exist at
  900.      all; flow of control may briefly move where you did not expect it;
  901.      some statements may not be executed because they compute constant
  902.      results or their values were already at hand; some statements may
  903.      execute in different places because they were moved out of loops.
  904.      Nevertheless it proves possible to debug optimized output. This
  905.      makes it reasonable to use the optimizer for programs still in the
  906.      testing phase.
  907.  
  908. `-s'
  909.      Remove all symbol table and relocation information from the
  910.      executable. Note: this has no influence on the performance of the
  911.      compiled executable.
  912.  
  913. `-Wall'
  914.      Give warnings for a number of constructs which are not inherently
  915.      erroneous but which are risky or suggest there may have been an
  916.      error. There are additional warning options not implied by
  917.      `-Wall', see the GCC warning options (*note Options to Request or
  918.      Suppress Warnings: (gcc)Warning Options.), while `-Wall' only
  919.      warns about such constructs that should be easy to avoid in
  920.      programs. Therefore, we suggest using `-Wall' on most sources.
  921.  
  922. `-Werror'
  923.      Turn all warnings into errors.
  924.  
  925. `-S'
  926.      Stop after the stage of compilation proper; do not assemble. The
  927.      output is in the form of an assembler code file for each source
  928.      file. By default, the assembler file name for a source file is made
  929.      by replacing the extension with `.s'.
  930.  
  931. `-c'
  932.      Compile and assemble the source files, but do not link. The output
  933.      is in the form of an object file for each source file. By default,
  934.      the object file name for a source file is made by replacing the
  935.      extension with `.o'.
  936.  
  937. `-static'
  938.      On systems that support dynamic linking, this prevents linking with
  939.      the shared libraries, i.e. forces static linking. On other systems,
  940.      this option has no effect.
  941.  
  942. `-DMACRO[=DEFN]'
  943.      Define the macro and conditional MACRO as DEFN (or as `1' if DEFN
  944.      is omitted).
  945.  
  946. `-b MACHINE'
  947.      The argument MACHINE specifies the target machine for compilation.
  948.      This is useful when you have installed GNU Pascal as a
  949.      cross-compiler.
  950.  
  951. `-v'
  952.      Print (on standard error) the commands executed to run the stages
  953.      of compilation. Also print the version number of the compiler
  954.      driver program and of the preprocessor and the compiler proper.
  955.  
  956. `--standard-pascal-level-0'
  957. `--standard-pascal'
  958. `--extended-pascal'
  959. `--object-pascal'
  960. `--borland-pascal'
  961. `--pascal-sc'
  962.      GNU Pascal supports the features of several different Pascal
  963.      standards and dialects. By default, they are all enabled. These
  964.      switches tell GPC to restrict itself to the features of the
  965.      specified standard. It does not enable any additional features.
  966.      Warnings about constructs which would be legal in the specified
  967.      dialect (e.g. assignment to a typed constant with
  968.      `--borland-pascal') are suppressed.
  969.  
  970.      By default, GNU Pascal allows redefinition of keywords. Each of
  971.      these switches causes GNU Pascal to forbid the redefinition of
  972.      keywords of the specified standard.
  973.  
  974.      Valid ISO Standard Pascal programs should compile properly with or
  975.      without `--standard-pascal'. However, without this option, certain
  976.      GNU extensions and Pascal features from other dialects are
  977.      supported as well. With this option, they are rejected.
  978.  
  979.      These options are not intended to be useful; they exist only to
  980.      satisfy pedants who would otherwise claim that GNU Pascal fails to
  981.      support the ISO Standard or is not really compatible to Borland
  982.      Pascal, or whatever. We recommend, rather, that users take
  983.      advantage of the extensions of GNU Pascal and disregard the
  984.      limitations of other compilers.
  985.  
  986. `-pedantic-errors'
  987.      Produce errors rather than warnings for portability violations.
  988.      Unlike in C, this does _not_ imply the `-pedantic' option, so you
  989.      can, for instance, use `-pedantic-errors' without `-pedantic', but
  990.      with `--extended-pascal'.
  991.  
  992. `--gpc-main=NAME'
  993.      Name the entry point of the main program `NAME' instead of `main'
  994.      on the linker level. This is useful, e.g., when working with some
  995.      C libraries which define their own `main' function and require the
  996.      program's main entry point to be named differently.
  997.  
  998. 
  999. File: gpc.info,  Node: Programming,  Next: Reference,  Prev: Invoking GPC,  Up: Top
  1000.  
  1001. The Programmer's Guide to GPC
  1002. *****************************
  1003.  
  1004.    *This chapter is still under development.*
  1005.  
  1006.    This chapter tells you how the source of a valid GNU Pascal program
  1007. should look like.  You can use it as tutorial about the GNU Pascal
  1008. language, but since the main goal is to document all special GPC
  1009. features, implementation-dependent stuff, etc., expect a steep learning
  1010. curve.
  1011.  
  1012.    This chapter does _not_ cover how to compile your programs and to
  1013. produce an executable - this is discussed above in *Note Invoking GPC::.
  1014.  
  1015. * Menu:
  1016.  
  1017. * Source Structures::            Programs, Units and Modules.
  1018. * Data Types::                   Standard and non-standard data types.
  1019. * Operators::                    Built-in and user-definable operators.
  1020. * Parameters::                   Procedure And Function Parameters
  1021. * Pointer Arithmetics::          How pointer arithmetics works in Pascal.
  1022. * Type Casts::                   Explicit and emulated type casting in GPC.
  1023. * OOP::                          How object-orientated programming is implemented.
  1024. * Compiler Directives::          Compiler Directives And The Preprocessor
  1025. * Library Routines::             Routines Built-in or in the Run Time System
  1026. * Other Languages::              How to share libraries with other languages.
  1027. * Notes for Debugging::          Problems and caveats when debugging GPC programs.
  1028. * Run Time System::              Pascal declarations for GPC's Run Time System library.
  1029. * GPC Units::                    Units included with GPC
  1030.  
  1031. 
  1032. File: gpc.info,  Node: Source Structures,  Next: Data Types,  Up: Programming
  1033.  
  1034. Source Structures
  1035. =================
  1036.  
  1037.    A source file accepted by GNU Pascal may contain up to one program,
  1038. zero or more ISO-style modules, and/or zero or more UCSD-style units.
  1039. Units and modules can be mixed in one project.
  1040.  
  1041. * Menu:
  1042.  
  1043. * The Program::                 The Source Structure of Programs
  1044. * Label Declaration::
  1045. * Constant Declaration::
  1046. * Type Declaration::
  1047. * Variable Declaration::
  1048. * Subroutine Declaration::      Procedures, Functions and Operators
  1049. * Statements::                  Loops and Conditional Statements
  1050. * Modules and Units::           Import Part and Module/Unit Concept
  1051.  
  1052.    One trivial example for a valid GPC source file follows. Note that
  1053. the code below may either be in one source file, or else the unit and
  1054. the program may be in separate source files.
  1055.  
  1056.      unit DemoUnit;
  1057.      
  1058.      interface
  1059.      
  1060.      procedure Hello;
  1061.      
  1062.      implementation
  1063.      
  1064.      procedure Hello;
  1065.      begin
  1066.        WriteLn ('Hello, world!')
  1067.      end;
  1068.      
  1069.      end.
  1070.      
  1071.      program UnitDemo;
  1072.      
  1073.      uses
  1074.        DemoUnit;
  1075.      
  1076.      begin
  1077.        Hello
  1078.      end.
  1079.  
  1080. 
  1081. File: gpc.info,  Node: The Program,  Next: Label Declaration,  Up: Source Structures
  1082.  
  1083. The Source Structure of Programs
  1084. --------------------------------
  1085.  
  1086.    A generic GNU Pascal program looks like the following:
  1087.  
  1088.      program NAME (Input, Output);
  1089.      
  1090.      IMPORT PART
  1091.      
  1092.      DECLARATION PART
  1093.      
  1094.      begin
  1095.        STATEMENT PART
  1096.      end.
  1097.  
  1098.    The `program' headline may be omitted in GPC, but a warning will be
  1099. given except in `--borland-pascal' mode.
  1100.  
  1101.    While the program parameters (usually `Input', `Output') are
  1102. obligatory in ISO Pascal if you want to use `ReadLn' and `WriteLn',
  1103. they are optional in GNU Pascal. GPC will warn about such missing
  1104. parameters in `--extended-pascal' mode. However if you give parameters
  1105. to the program headline, they work like ISO requires.
  1106.  
  1107.    The IMPORT PART consists either of an ISO-style `import'
  1108. specification or a UCSD/Borland-style `uses' clause. While `import' is
  1109. intended to be used with interfaces exported by ISO-10206 Extended
  1110. Pascal modules, and `uses' is intended to be used with units, this is
  1111. not enforced. (See also *Note uses::, *Note import::.)
  1112.  
  1113.    The DECLARATION PART consists of label, constant, type, variable or
  1114. subroutine declarations in free order. However, every identifier must
  1115. be declared before it is used. The only exception are type identifiers
  1116. pointing to another type identifier which may be declared below.
  1117.  
  1118.    The STATEMENT PART consists of a sequence of statements.
  1119.  
  1120.    As an extension, GPC supports a "declaring statement" which can be
  1121. used in the statement part to declare variables (see *Note var::).
  1122.  
  1123. 
  1124. File: gpc.info,  Node: Label Declaration,  Next: Constant Declaration,  Prev: The Program,  Up: Source Structures
  1125.  
  1126. Label Declaration
  1127. -----------------
  1128.  
  1129.    A label declaration has the following look:
  1130.  
  1131.      label
  1132.        LABEL NAME, ..., LABEL;
  1133.  
  1134.    A label declaration part starts with the reserved word `label',
  1135. which contains a list of labels.
  1136.  
  1137.  
  1138.    *See also* *Note label::, *Note goto::
  1139.  
  1140. 
  1141. File: gpc.info,  Node: Constant Declaration,  Next: Type Declaration,  Prev: Label Declaration,  Up: Source Structures
  1142.  
  1143. Constant Declaration
  1144. --------------------
  1145.  
  1146.    A constant declaration has the following look:
  1147.  
  1148.      const
  1149.        CONSTANT IDENTIFIER = CONSTANT EXPRESSION;
  1150.        ...
  1151.        CONSTANT IDENTIFIER = CONSTANT EXPRESSION;
  1152.  
  1153.    A constant declaration part starts with the reserved word `const'.
  1154. It declares a CONSTANT IDENTIFIER which is defined by CONSTANT
  1155. EXPRESSION. This expression has to be evaluatable during compilation
  1156. time, i.e. it can include numbers, parentheses, predefined operators,
  1157. sets and type casts (the last, however, is a Borland extension).  In
  1158. ISO-7185 Pascal, CONSTANT EXPRESSION must be a constant or a set. All
  1159. Pascal Dialects but ISO-Pascal allow the use of these intrinsic
  1160. functions in CONSTANT EXPRESSION:
  1161.  
  1162.  
  1163.    *Note Abs::, *Note Round::, *Note Trunc::,
  1164.  
  1165.  
  1166.    *Note Chr::, *Note Ord::,
  1167.  
  1168.  
  1169.    *Note Length::, *Note Pred::, *Note Succ::,
  1170.  
  1171.  
  1172.    *Note SizeOf::, *Note Odd::.
  1173.  
  1174.  
  1175.    In Borland Pascal, in the constant declaration part variables can be
  1176. declared as well, which are given an initial value. These variables are
  1177. called "typed constants". It is good style to avoid this use,
  1178. especially since Extended Pascal and GNU Pascal allow to initialize a
  1179. variable in variable declaration part or give a type a preset value on
  1180. declaration.
  1181.  
  1182.      const
  1183.        FiveFoo      = 5;
  1184.        StringFoo    = 'string constant';
  1185.        AlphabetSize = Ord ('Z') - Ord ('A') + 1;
  1186.      
  1187.      type
  1188.        PInteger     = ^Integer;     { Define a pointer to an Integer }
  1189.      
  1190.      const
  1191.        { Constant which holds a pointer to an Integer at address 1234 }
  1192.        AddressFoo   = PInteger (1234);
  1193.  
  1194.    * BP does not know initialized variables, only typed constants. Even
  1195.      worse, it allows them to be misused as variables, without even
  1196.      warning. GPC supports this (unwillingly ;-), and warns unless in
  1197.      `--borland-pascal' mode.
  1198.  
  1199.      An example of a typed constant:
  1200.  
  1201.           const
  1202.             i : Integer = 0;
  1203.  
  1204.      If you want to use it as a constant only, that's perfectly fine.
  1205.      However, if you modify `i', we suggest to translate the
  1206.      declaration to an initialized variable. The EP syntax is:
  1207.  
  1208.           var
  1209.             i : Integer value 0;
  1210.  
  1211.      GPC supports this as well as the following mixtureof dialects:
  1212.  
  1213.           var
  1214.             i : Integer = 0;
  1215.  
  1216.      Furthermore, you can also assign initialization values to types:
  1217.  
  1218.           program InitTypeDemo;
  1219.           
  1220.           type
  1221.             MyInteger = Integer value 42;
  1222.           
  1223.           var
  1224.             i : MyInteger;
  1225.           
  1226.           begin
  1227.             WriteLn (i)
  1228.           end.
  1229.  
  1230.      Here, all variables of type MyInteger are automatically initialized
  1231.      to 0 when created.
  1232.  
  1233.    * Arrays initializers look like this in BP:
  1234.  
  1235.           program BPArrayInitDemo;
  1236.           
  1237.           const
  1238.             MyStringsCount = 5;
  1239.           
  1240.           type
  1241.             Ident = String [20];
  1242.           
  1243.           const
  1244.             MyStrings : array [1 .. MyStringsCount] of Ident =
  1245.               ('export', 'implementation', 'import',
  1246.                'interface', 'module');
  1247.           
  1248.           begin
  1249.           end.
  1250.  
  1251.      And the following way in EP:
  1252.  
  1253.           program EPArrayInitDemo;
  1254.           
  1255.           {$W no-field-name-problem} { avoid a warning by GPC }
  1256.           
  1257.           const
  1258.             MyStringsCount = 5;
  1259.           
  1260.           type
  1261.             Ident = String (20);
  1262.           
  1263.           var
  1264.             MyStrings : array [1 .. MyStringsCount] of Ident value
  1265.               [1 : 'export'; 2 : 'implementation'; 3 : 'import';
  1266.                4 : 'interface'; 5 : 'module'];
  1267.           
  1268.           begin
  1269.           end.
  1270.  
  1271.      There seem to be pros and cons to each style. GPC supports both as
  1272.      well as just about any thinkable mixture of them.
  1273.  
  1274.      Some folks don't like having to specify an index since it requires
  1275.      renumbering if you want to add a new item to the middle. However,
  1276.      if you index by an enumerated type, you might be able to avoid
  1277.      major renumbering by hand.
  1278.  
  1279.  
  1280.    *See also* *Note Subroutine Parameter List Declaration::
  1281.  
  1282. 
  1283. File: gpc.info,  Node: Type Declaration,  Next: Variable Declaration,  Prev: Constant Declaration,  Up: Source Structures
  1284.  
  1285. Type Declaration
  1286. ----------------
  1287.  
  1288.    A type declaration looks like this:
  1289.  
  1290.      type
  1291.        TYPE IDENTIFIER = TYPE DEFINITION;
  1292.        ...
  1293.        TYPE IDENTIFIER = TYPE DEFINITION;
  1294.    or, with preset content:
  1295.      type
  1296.        TYPE IDENTIFIER = TYPE DEFINITION value CONSTANT EXPRESSION;
  1297.        ...
  1298.        TYPE IDENTIFIER = TYPE DEFINITION value CONSTANT EXPRESSION;
  1299.  
  1300.    A type declaration part begins with the reserved word `type'.  It
  1301. declares a TYPE IDENTIFIER which is defined by TYPE DEFINITION.  A type
  1302. definition either can be an array, a record, a schema, a set, an
  1303. object, a subrange, an enumerated type, a pointer to another type
  1304. identifier or simply another type identifier which is to alias.  If a
  1305. schema type is to be declared, TYPE IDENTIFIER is followed by a
  1306. discriminant enclosed in parentheses:
  1307.  
  1308.      TYPE IDENTIFIER (DISCRIMINANT) = SCHEMA TYPE DEFINITION;
  1309.  
  1310.    If `value' is specified, followed by a constant satisfying the type
  1311. definition, every variable of this type is initialized with CONSTANT
  1312. EXPRESSION, unless it is initialized by `value' itself.  The reserved
  1313. word `value' can be replaced by `=', however `value' is not allowed in
  1314. ISO-Pascal and Borland Pascal, and the replacement by `=' is not
  1315. allowed in Extended Pascal.
  1316.  
  1317.  
  1318.    Type declaration example:
  1319.  
  1320.      type
  1321.        { This side is the }     { That side is the }
  1322.        { type declaration }     { type definition  }
  1323.      
  1324.        arrayfoo            = array [0..9] of Integer;  { array definition }
  1325.        recordfoo           = record                    { record definition }
  1326.                                bar : Integer;
  1327.                              end;
  1328.      
  1329.             { schema def with discriminant ``x,y : Integer'' }
  1330.        schemafoo (x,y : Integer) = array [x..y] of Integer;
  1331.        charsetfoo          = set of Char;              { Def of a set }
  1332.        objectfoo           = object                    { Def of an object }
  1333.                                procedure DoAction;
  1334.                                constructor Init;
  1335.                                destructor Done;
  1336.                              end;
  1337.        subrangefoo         = -123..456;                { subrange def }
  1338.      
  1339.        enumeratedfoo       = (Pope,John,the,Second);   { enum type def }
  1340.             { Def of a pointer to another type identifier }
  1341.        pinteger            = ^arrayfoo;
  1342.             { Def of an alias name for another type identifier }
  1343.        identityfoo         = Integer;
  1344.             { Def of an integer which was initialized by 123 }
  1345.        initializedfoo      = Integer value 123;
  1346.  
  1347.  
  1348.    *See also*  *Note Type Definition::, *Note Data Types::, *Note
  1349. Variable Declaration::
  1350.  
  1351. 
  1352. File: gpc.info,  Node: Variable Declaration,  Next: Subroutine Declaration,  Prev: Type Declaration,  Up: Source Structures
  1353.  
  1354. Variable Declaration
  1355. --------------------
  1356.  
  1357.    A variable declaration looks like this:
  1358.  
  1359.      var
  1360.        VARIABLE IDENTIFIER: TYPE IDENTIFIER;
  1361.        ...
  1362.        VARIABLE IDENTIFIER: TYPE IDENTIFIER;
  1363.    or
  1364.      var
  1365.        VARIABLE IDENTIFIER: TYPE DEFINITION;
  1366.        ...
  1367.        VARIABLE IDENTIFIER: TYPE DEFINITION;
  1368.    and with initializing value:
  1369.      var
  1370.        VARIABLE IDENTIFIER: TYPE IDENTIFIER value CONSTANT EXPRESSION;
  1371.        ...
  1372.        VARIABLE IDENTIFIER: TYPE IDENTIFIER value CONSTANT EXPRESSION;
  1373.    or
  1374.      var
  1375.        VARIABLE IDENTIFIER: TYPE DEFINITION value CONSTANT EXPRESSION;
  1376.        ...
  1377.        VARIABLE IDENTIFIER: TYPE DEFINITION value CONSTANT EXPRESSION;
  1378.  
  1379.    A variable declaration part begins with the reserved word `var'.  It
  1380. declares a VARIABLE IDENTIFIER whose type either can be specified by a
  1381. type identifier, or by a type definion which either can be an array, a
  1382. record, a set, a subrange, an enumerated type or a pointer to an type
  1383. identifier.  If `value' is specified followed by a constant expression
  1384. satisfying the specified type, the variable declared is initialized with
  1385. CONSTANT EXPRESSION.  The reserved word `value' can be replaced by `=',
  1386. however `value' is not allowed in ISO-Pascal and Borland Pascal, and the
  1387. replacement by `=' is not allowed in Extended Pascal.
  1388.  
  1389.  
  1390.    *See also* *Note Type Definition::, *Note Type Declaration::, *Note
  1391. Data Types::, *Note The Declaring Statement::, *Note Subroutine
  1392. Parameter List Declaration::
  1393.  
  1394. 
  1395. File: gpc.info,  Node: Subroutine Declaration,  Next: Statements,  Prev: Variable Declaration,  Up: Source Structures
  1396.  
  1397. Subroutine Declaration
  1398. ----------------------
  1399.  
  1400. * Menu:
  1401.  
  1402. * The Procedure::
  1403. * The Function::
  1404. * The Operator::
  1405. * Subroutine Parameter List Declaration::
  1406.  
  1407. 
  1408. File: gpc.info,  Node: The Procedure,  Next: The Function,  Up: Subroutine Declaration
  1409.  
  1410. The Procedure
  1411. .............
  1412.  
  1413.      procedure PROCEDURE IDENTIFIER;
  1414.      DECLARATION PART
  1415.      begin
  1416.        STATEMENT PART
  1417.      end;
  1418.    or with a parameter list:
  1419.      procedure PROCEDURE IDENTIFIER (PARAMETER LIST);
  1420.      DECLARATION PART
  1421.      begin
  1422.        STATEMENT PART
  1423.      end;
  1424.  
  1425.    A procedure is quite like a sub-program: The DECLARATION PART
  1426. consists of label, constant, type, variable or subroutine declarations
  1427. in free order. The STATEMENT PART consists of a sequence of statements.
  1428. If PARAMETER LIST is specified, parameters can be passed to the
  1429. procedure and can be used in STATEMENT PART. A recursive procedure call
  1430. is allowed.
  1431.  
  1432.  
  1433.    *See also* *Note The Function::, *Note Subroutine Parameter List
  1434. Declaration::
  1435.  
  1436.